$(function() {
	$("#btn_login").click(function() {
		var content = {};
		content.title = '警告提示';
		var username = $("#username").val();
		var password = $("#password").val();
		var flag = true;
		if (username == '' || password == '') {
			flag = false;
			content.message = '用户名或密码不能为空';
			$.notify(content, {
				type: "warning",
				placement: {
					from: "top",
					align: "center"
				},
				time: 1000,
				delay: 1,
			});
		}
		if (flag) {
			$.ajax({
				type: "POST",
				url: "http://127.0.0.1:8080/mgrUser/mgrLogin",
				dataType: "json",
				xhrFields: {
					withCredentials: true
				},
				data: {
					"userName": username,
					"password": password
				},
				success: function(data) {
					var code = data.code;
					if (code == 'success') {
						window.location.href = './index.html';
					} else {
						flag = false;
						content.message = data.msg;
						$.notify(content, {
							type: "warning",
							placement: {
								from: "top",
								align: "center"
							},
							time: 1000,
							delay: 1,
						});
					}
				}
			})
		}
	})
})
